Finds the file on disk (file system)
Loads Python interpreter into memory (memory management)
Loads your script into memory
Gives Python CPU time to run (process management)
Sends output to your terminal (I/O management)
By the end of this session, you’ll be able to:
Explain how computers store and process data
Describe what an operating system does and why it matters
Navigate a file system using the command line
Understand the difference between absolute and relative paths
Use essential terminal commands for your Python workflow
a programmable usually electronic device that can store, retrieve, and process data
Three key capabilities:
Store — remember information (memory, disk)
Retrieve — access stored information
Process — transform data according to instructions
Which of these are computers? Discuss with a neighbor.
A smartphone
A microwave oven
A digital thermostat
A basic calculator
A car’s engine control unit
Turn to a neighbor and discuss for 60 seconds.
All of them! Each can store, retrieve, and process data according to programmable instructions—though some are more general-purpose than others.
CPU | Central Processing Unit — executes instructions |
Memory | RAM — fast, temporary storage |
Storage | Disk/SSD — persistent data |
I/O | Input/Output — keyboard, screen, network |
When you run a Python program:
Your code loads from storage into memory
The CPU executes each instruction
Results display via I/O (your screen)
As computers became more complex, problems arose:
How do we run multiple programs at once?
How do we let multiple users share one machine?
How do we protect data from unauthorized access?
How do we manage hardware so programs don’t conflict?
The operating system (OS) solves all of these problems.
Memory Management | Allocates RAM to programs, prevents conflicts |
Process Management | Runs multiple programs, shares CPU time |
File System | Organizes data on disk, controls access |
Security | Authenticates users, enforces permissions |
I/O Management | Handles keyboards, displays, networks |
Command Interface | Lets you interact (GUI or command line) |
Windows | Most common for personal computers, gaming |
macOS | Apple computers, popular with developers |
Linux | Servers, cloud computing, development |
iOS/Android | Mobile devices |
Fun fact: macOS and Linux are both based on Unix, which is why their terminals are similar!
When you double-click a Python file to run it, what does the OS do?
Turn to a neighbor and discuss for 60 seconds.
Finds the file on disk (file system)
Loads Python interpreter into memory (memory management)
Loads your script into memory
Gives Python CPU time to run (process management)
Sends output to your terminal (I/O management)
As a Python developer, you’ll use the terminal to:
Run Python scripts: python my_script.py
Install packages: pip install pandas
Manage files: Create, move, delete files and folders
Use version control: git commit, git push
Access remote servers: Work on cloud machines
The terminal is your power tool.
Windows | Search for "PowerShell" or "Command Prompt" |
macOS | Applications → Utilities → Terminal |
Linux | Usually Ctrl+Alt+T, or search "Terminal" |
When you open it, you’ll see a prompt waiting for your command:
# Mac/Linux might look like:
username@computer ~ $
# Windows might look like:
PS C:\Users\username>command -options argumentsls -la /home/user/documents
| The command (list files) |
| Options (l=long format, a=show hidden) |
| Argument (which directory to list) |
| Mac/Linux | Windows | What it does |
|---|---|---|
|
| Print Working Directory (where am I?) |
|
| List files in current directory |
|
| Change Directory (move to folder) |
|
| Go up one level (parent directory) |
|
| Go to home directory |
Note | PowerShell supports both ls and dir, and cd ~ works too! |
| Mac/Linux | Windows | What it does |
|---|---|---|
|
| Make a new directory |
|
| Create an empty file |
|
| Copy a file |
|
| Move or rename a file |
|
| Remove (delete) a file |
|
| Display file contents |
rm important_file.txt # Gone forever!
rm -r entire_folder/ # Deletes folder AND everything in it!There is no Trash or Recycle Bin in the terminal. Deleted files are gone immediately.
Tips:
Double-check your command before pressing Enter
Use ls first to see what you’re about to delete
Consider mv file.txt ~/.trash/ as a safer alternative
Open your terminal and try these commands:
pwd # Where are you?
ls # What's here?
cd Desktop # Go to Desktop (or another folder)
pwd # Confirm you moved
ls # What's on your Desktop?
cd .. # Go back up
pwd # Confirm you're backWork through these with a partner. Help each other!
Files are organized in a hierarchical structure—folders within folders.
/ ← Root (top of the tree)
├── home/
│ └── alice/ ← Alice's home directory
│ ├── Documents/
│ │ └── essay.txt
│ ├── Downloads/
│ └── projects/
│ └── inst326/
│ └── hw1.py
├── usr/
│ └── bin/
└── etc/Root Directory | The topmost level of the entire file system |
Home Directory | Your personal folder (where your files live) |
# Root directory
/ # Mac/Linux
C:\ # Windows
# Home directory
/home/username # Linux
/Users/username # Mac
C:\Users\username # WindowsThe ~ symbol is a shortcut for your home directory.
A path is the address of a file in the file system.
Absolute path: Full address from root
/home/alice/projects/inst326/hw1.py # Mac/Linux
C:\Users\Alice\projects\inst326\hw1.py # WindowsRelative path: Address from current location
projects/inst326/hw1.py # If you're in /home/alice
../Documents/essay.txt # Go up one level, then into DocumentsYou are in /home/alice/projects. Where do these paths point?
./hw1.py
../Documents
../../bob
/home/aliceTurn to a neighbor and discuss for 60 seconds.
./hw1.py # /home/alice/projects/hw1.py
../Documents # /home/alice/Documents
../../bob # /home/bob
/home/alice # /home/alice (absolute, ignores current location)When you work with files in Python, you need correct paths:
# This only works if data.txt is in the current directory
with open("data.txt", "r") as f:
content = f.read()
# This works from anywhere (absolute path)
with open("/home/alice/projects/data.txt", "r") as f:
content = f.read()
# This works if you're in the project's parent directory
with open("my_project/data.txt", "r") as f:
content = f.read()Tip: Use pwd to check where Python thinks you are!
From your home directory, figure out:
The absolute path to your Desktop
The relative path from Desktop to Documents
What cd ~/Documents/../Downloads would do
# 1. Absolute path to Desktop
/Users/yourname/Desktop # Mac
/home/yourname/Desktop # Linux
C:\Users\yourname\Desktop # Windows
# 2. Relative from Desktop to Documents
../Documents
# 3. cd ~/Documents/../Downloads
# Goes to home, then Documents, then up, then Downloads
# Ends up in ~/Downloads (the long way!)A file is packaged data with:
A name (including extension)
A format that determines how to interpret the data
A location in the file system
my_script.py # Python source code (text)
data.csv # Comma-separated values (text)
photo.jpg # Image (binary)
document.pdf # Portable Document Format (binary)| Text Files | Binary Files |
|---|---|
Human-readable | Not human-readable |
Open in any text editor | Need specific programs |
Line-based (usually) | Various structures |
.txt, .py, .csv, .html, .json | .jpg, .pdf, .exe, .zip, .mp3 |
cat script.py # Shows readable Python code
cat photo.jpg # Shows garbage characters!Your .py files are just text files with Python code:
$ cat hello.py
print("Hello, world!")
$ python hello.py
Hello, world!This means you can:
Edit them in any text editor
View them with cat or type
Create them with touch or echo
Use the terminal to create and run a simple Python script:
# Navigate to a good location
cd ~/Desktop
# Create a new file
echo 'print("Hello from the terminal!")' > hello.py
# Verify it was created
cat hello.py
# Run it
python hello.pyWork through this with a partner!
# 1. Navigate to your project
cd ~/projects/inst326
# 2. Check what's there
ls
# 3. Create a new directory for today's work
mkdir week2
# 4. Move into it
cd week2
# 5. Create a new Python file
touch exercise.py
# 6. Edit it (opens your editor)
code exercise.py # or nano, vim, etc.
# 7. Run your script
python exercise.py| Problem | Solution |
|---|---|
"File not found" when running Python | Check you’re in the right directory ( |
Created file in wrong location | Use |
Forgot where you saved something | Use |
Typed wrong command | Press Up arrow to recall previous commands |
| Navigation | Files | Info |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Navigation | Files | Info |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Computer Architecture | CPU + Memory + Storage + I/O |
Operating System | Manages hardware, runs programs, controls access |
Terminal | Text interface for controlling your computer |
File System | Hierarchical tree of directories and files |
Paths | Absolute (from root) vs. Relative (from current) |
Python Files | Just text files that Python interprets |
Using only the terminal:
Create a new directory called practice on your Desktop
Navigate into it
Create a file called greeting.py
Use echo to write print("Hello, INST326!") into it
Run the script with Python
Verify it worked!
Work with a partner. Help each other debug!
# 1. Create directory
mkdir ~/Desktop/practice
# 2. Navigate into it
cd ~/Desktop/practice
# 3. Create file (touch creates empty, but we'll write directly)
# 4. Write the print statement
echo 'print("Hello, INST326!")' > greeting.py
# 5. Run it
python greeting.py
# 6. Verify
ls # Should show greeting.py
cat greeting.py # Should show the print statementOutput:
Hello, INST326!
🔗 Resources:
Terminal Cheat Sheet: https://www.git-tower.com/blog/command-line-cheat-sheet/
Explain Shell (breaks down commands): https://explainshell.com/
Linux Command Library: https://linuxcommandlibrary.com/